package edu.sctu.zhoudie.mouth201506.day20150614.teacher;


import java.io.*;


/**
 * Created by user08 on 2015/6/14.
 */
public class MyIO {
    public void myIntputstream() {
        FileInputStream inputStream;
        FileOutputStream outputStream;
        int count = 0;
        int counts = 0;
        byte[] buffer = new byte[1024];
        try {
            inputStream = new FileInputStream("D://新建位图图像.bmp");
            outputStream = new FileOutputStream("D://新建位图图像1.bmp");
            try {
                while ((count = inputStream.read(buffer)) != -1) {
                    counts += count;
                    outputStream.write(buffer, 0, count);

                }
                System.out.println(counts);

            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                outputStream.close();
                inputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();

        }
    }

    public void myReader() {
        InputStreamReader steamReader;
        OutputStreamWriter streamWriter;
        int count = 0;
        int counts = 0;
        char[] buffer = new char[1];
        try {
            steamReader = new InputStreamReader(new FileInputStream("D://xxx.txt"));
            streamWriter = new OutputStreamWriter(new FileOutputStream("D://xxx1.txt"));
            try {
                while ((count = steamReader.read(buffer)) != -1) {

                    streamWriter.write(buffer, 0, count);
                    System.out.println(buffer);

                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                steamReader.close();
                streamWriter.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
